#!/usr/bin python3
# -*- coding:UTF-8 -*-
# Author: nigo
import pandas as pd
import plotly.express as px

# 数据
df = pd.DataFrame([
    ["2019-01", 677.59 ],
    ["2019-02", 670.82 ],
    ["2019-03", 690.02 ],
    ["2019-04", 689.96 ],
    ["2019-05", 701.50 ],
    ["2019-06", 705.37 ],
    ["2019-07", 681.74 ],
    ["2019-08", 649.31 ],
    ["2019-09", 629.75 ],
    ["2019-10", 623.21 ],
    ["2019-11", 630.22 ],
    ["2019-12", 621.71 ],
],columns=[ "月份" , "平均消费额" ])
avg = df['平均消费额'].mean()
df['年平均消费额'] = avg
# 轨迹+画布
# fig = px.line(x=df['月份'],y=[df['平均消费额'],[avg]*len(df)])
fig = px.line(df,x='月份',y=['平均消费额','年平均消费额'],title='订单平均消费额分析')
fig.update_layout(xaxis_tickformat='%Y-%m',yaxis_range=[500,750])
fig.show()
